//
//  ViewController.swift
//  ChangeAppIcon
//
//  Created by 波波 on 2019/4/29.
//  Copyright © 2019 波波. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


    @IBAction func changeAppIcon(_ sender: UIButton) {
        if ChangeAppIconManager.isSupportChangeAppIcon() {
            let actionSheetVC = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
            let defaultAction = UIAlertAction.init(title: "默认", style: .default) { (action: UIAlertAction) in
                ChangeAppIconManager.changeAppIcon(nil)
            }
            let bmwAction = UIAlertAction.init(title: "宝马", style: .default) { (action: UIAlertAction) in
                ChangeAppIconManager.changeAppIcon("BMW")
            }
            let benzitAction = UIAlertAction.init(title: "奔驰", style: .default) { (action: UIAlertAction) in
                ChangeAppIconManager.changeAppIcon("Benzi")
            }
            actionSheetVC.addAction(defaultAction)
            actionSheetVC.addAction(bmwAction)
            actionSheetVC.addAction(benzitAction)
            let appDelegate = UIApplication.shared.delegate as! AppDelegate
            appDelegate.window?.rootViewController?.present(actionSheetVC, animated: true, completion: nil)
        }
    }
}

